<%@ page contentType="text/html; charset=UTF-8" language="java"
	import="java.util.*,org.yoao.crm.acl.ACLTool,org.yoao.crm.page.framework.IViewPageService,org.yoao.crm.page.framework.ViewPageHelper,org.yoao.moneymachine.bean.File"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
	org.yoao.crm.bean.Session userSession = (org.yoao.crm.bean.Session) session
			.getAttribute("userSession");
	String actionPermission = userSession.getActionPermission();
	IViewPageService filePage = (IViewPageService) session
			.getAttribute(ViewPageHelper.SESSION_PAGE);

	List list = (List) request.getAttribute("FILELIST");

	org.yoao.crm.bean.Session httpSession = (org.yoao.crm.bean.Session) session
			.getAttribute("userSession");

	String searchName = (String) request.getAttribute("searchName");
	if (searchName == null)
		searchName = "";
%>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title>网络赚钱机器-文件列表</title>
		<jsp:include page="../public/publicJs.jsp" flush="false"></jsp:include>
		<script type="text/javascript">
var preTr = null;
var preColor = "";
function changeTrColor() {
	try {
		var tag = event.srcElement;
		while (tag.tagName != "TR")
			tag = tag.parentElement;
		switch (event.type) {
		case "mouseover":
			preColor = tag.currentStyle.backgroundColor;
			if (tag.currentStyle.highLightColor)
				tag.style.background = tag.currentStyle.highLightColor;
			else
				tag.style.background = "#FFFF00";
			break;
		case "mouseout":
			if (preTr != tag)
				tag.style.background = preColor;
			break;
		}
	} catch (E) {
	}
}

function downLoad(vUrl) {
	if (vUrl == null)
		return;
	var fileName = vUrl.substring(vUrl.lastIndexOf("/"));
	var url = vUrl;
	var obj = window.open(url, "", fnGetWinStatus(100, 100));
	obj.document.execCommand('Saveas', true, fileName);
	obj.close();
}
</script>
	</head>

	<body topmargin="0" leftmargin="0"
		onLoad="setDivHeight('divList', -107);">
		<div id="div_load"
			style='display: block; background: #FFFFFF; width: 240px; height: 12px; margin-top: -120px; margin-left: -200px; left: 50%; top: 50%; position: absolute; padding: 5px 5px 5px 5px; z-index: 1'>
			<img src="<%=basePath%>images/loading.gif" class="icon1"
				align="absmiddle" />
			数据加载中,请稍后...
		</div>
		<table class="maintab_content_table" border="0" width="100%"
			cellspacing="0" cellpadding="0" height="25">
			<tr class="tree_title_txt">
				<td nowrap width="100%" class="tree_title_txt" valign="middle"
					id="cwCellTopTitTxt">
					<font color="#154288">文件列表 </font>
				</td>
			</tr>
		</table>

		<div id="ds"
			style="display: none; background: #EBEBEB; width: 100px; height: 20px; left: 50%; top: 50%; position: absolute; padding: 5px 5px 5px 5px; z-index: 1">
			<font color="#FF0000"><img
					src="<%=basePath%>images/loading.gif" alt="数据加载中" align="absmiddle" />数据加载中...</font>
		</div>
		<div style="width: 100%;">
			<fieldset
				style="width: 100%; TEXT-ALIGN: center; margin: 0px 5px 0px 5px;">
				<legend>
					&nbsp;搜索
					<img name="Changeicon" border="0"
						src="<%=basePath%>images/jt_b.gif"
						onClick="javascript:fieldsetHidden();" style="cursor: hand"
						title="显示/隐藏内容">
					&nbsp;
				</legend>
				<form name="searchForm" action="<%=basePath%>file.crm?method=view"
					method="post">
					<table border="0" width="100%" cellspacing="5" cellpadding="0">
						<tr>
							<td nowrap width="10%">
								文件名:
							</td>
							<td width="15%">
								<input name="searchName" accesskey="s" type="text"
									class="text_220" style="width: 150px" size="15"
									value="<%=searchName%>">
							</td>
							<td>
								<input name="image" type="image"
									src="<%=basePath%>images/tbtn_searh.gif" alt="查询"
									align="absmiddle" onclick="searchForm.submit();">
							</td>
						</tr>
					</table>
				</form>
			</fieldset>
		</div>

		<form action="<%=basePath%>file.crm?method=view" name="viewForm"
			method="post">
			<input name="searchName" type="hidden" value="<%=searchName%>">
			<table border="0" width="100%" height="25" cellspacing="0"
				cellpadding="0">
				<tr class="maintab">
					<td width="1%" align="center" valign="middle" id="cwCellTopTitTxt">
						&nbsp;
						<input type="checkbox" onClick="selectAction('itemselect')"
							value="1" />
					</td>
					<%
						if (ACLTool.isAdd(actionPermission)) {
					%>
					<td width="2%">
						<a href="#" accesskey="n"
							onClick="dataHander('exportin','<%=basePath%>kmjsp/file/file_add.jsp', viewForm.itemselect);"><img
								align="absmiddle" src="<%=basePath%>images/sbtn_new.gif"
								alt="新增(Alt+N)" align="absmiddle" /> </a>
					</td>
					<%
						}
						if (ACLTool.isDelete(actionPermission)) {
					%>
					<td width="2%">
						<a href="#" accesskey="d"
							onClick="dataHander('delete','<%=basePath%>file.crm?method=delete&id=', viewForm.itemselect);"><img
								align="absmiddle" src="<%=basePath%>images/sbtn_del.gif"
								alt="删除(Alt+D)" align="absmiddle"> </a>
					</td>
					<%
						}
					%>

					<td nowrap width="68%" align="right">
						<input id="<%=ViewPageHelper.PAGE_ACTION%>"
							name="<%=ViewPageHelper.PAGE_ACTION%>" type="hidden" value="" />
						共
						<%=filePage.getTotalRows()%>条 /
						<%=filePage.getPageCount()%>
						页
						<%
							if (filePage.getPageIndex() > 1) {
						%>
						<img align="absmiddle" style="cursor: pointer;"
							onClick="goPage('FIRST_PAGE')"
							src="<%=basePath%>images/ico_first.gif" alt="首页" border="0" />
						<img align="absmiddle" style="cursor: pointer;"
							onClick="goPage('PREVIOUS_PAGE')"
							src="<%=basePath%>images/ico_prev.gif" alt="上一页" border="0" />
						<%
							} else {
						%>
						<img align="absmiddle" style="filter: Gray;"
							src="<%=basePath%>images/ico_first.gif" alt="首页" border="0" />
						<img align="absmiddle" style="filter: Gray;"
							src="<%=basePath%>images/ico_prev.gif" alt="上一页" border="0" />
						<%
							}
						%>
						第
						<font color="red"><%=filePage.getPageIndex()%></font> 页
						<%
							if (filePage.getPageIndex() < filePage.getPageCount()) {
						%>
						<img align="absmiddle" style="cursor: pointer;"
							onClick="goPage('NEXT_PAGE')"
							src="<%=basePath%>images/ico_next.gif" alt="下一页" border="0" />
						<img align="absmiddle" style="cursor: pointer;"
							onClick="goPage('LAST_PAGE')"
							src="<%=basePath%>images/ico_last.gif" alt="尾页" border="0/">
						<%
							} else {
						%>
						<img align="absmiddle" style="filter: Gray;"
							src="<%=basePath%>images/ico_next.gif" alt="下一页" border="0" />
						<img align="absmiddle" style="filter: Gray;"
							src="<%=basePath%>images/ico_last.gif" alt="尾页" border="0" />
						<%
							}
						%>
					</td>
					<td nowrap width="1%">
						<img align="absmiddle" src="<%=basePath%>images/sbtn_split.gif" />
					</td>
					<td nowrap width="8%">
						转到&nbsp;
						<input id="<%=ViewPageHelper.PAGE_NO%>"
							name="<%=ViewPageHelper.PAGE_NO%>" type="text" size="2"
							value="<%=filePage.getPageIndex()%>"
							onKeyPress="javascript:if(event.keyCode == 13){goPage('jump');}" />
						&nbsp;页
						<img align="absmiddle" style="cursor: pointer;"
							onClick="goPage('jump')" src="<%=basePath%>images/goto.gif"
							alt="执行" border="0" align="absmiddle">
					</td>
				</tr>
			</table>
			<div id="divList"
				style="vertical-align: top; width: 100%; overflow: auto;">
				<table border="0" style="border-collapse: collapse;" align="center"
					cellpadding="0" cellspacing="0" width="100%"
					class="maintab_content_table">
					<tr class="maintab_content_table_title">
						<th width="1%"></th>
						<th align="center" nowrap>
							文件名
						</th>
						<th align="center" nowrap>
							访问路径
						</th>
						<th align="center" nowrap>
							下载权限
						</th>
						<th align="center" nowrap>
							上传时间
						</th>
					</tr>
					<%
						if (list != null) {
							int size = list.size();
							for (int i = 0; i < size; i++) {
								File file = (File) list.get(i);
								if ("ALL".equals(file.getAccessSno())) {
									file.setAccessSno("所有人");
								} else if ("GJ".equals(file.getAccessSno())) {
									file.setAccessSno("高级会员");
								}
					%>
					<tr onMouseOver="changeTrColor()" onMouseOut="changeTrColor()"
						title="<%=file.getFileName()%>">
						<td nowrap align="center">
							<input class="rd" type="checkbox" name="itemselect"
								value="<%=file.getId()%>" />
						</td>
						<td nowrap><%=file.getFileName() != null ? file.getFileName()
							: ""%></td>
						<td nowrap>
							<a
								href="<%=basePath%>regedit/down.jsp?url=<%=file.getFileUrl() != null ? file.getFileUrl()
							: ""%>"><%=file.getFileUrl() != null ? file.getFileUrl()
							: ""%></a>
						</td>
						<td nowrap align="center"><%=file.getAccessSno() != null ? file.getAccessSno()
							: ""%></td>
						<td nowrap align="center"><%=file.getCreateTime() != null ? file
							.getCreateTime() : ""%></td>
					</tr>
					<%
						}
						}
					%>
				</table>
			</div>
		</form>
	</body>
</html>
<script>
document.getElementById("div_load").style.display = "none";</script>